#include<stdio.h>
struct node
{
    int val;
    struct node *next_ptr;
    struct node *previous_ptr;
};
main()
{
    struct node nd1,nd2,nd3,nd4;
    struct node *start=&nd1;
    struct node *end=&nd4;
    struct node *ptr1,*ptr2;
    ptr1 = start;
    ptr2 = end;
    nd1.val=10;
    nd1.next_ptr=&nd2;
    nd2.val=20;
    nd2.next_ptr=&nd3;
    nd3.val=24;
    nd3.next_ptr=&nd4;
    nd4.val=50;
    nd4.next_ptr=NULL;
    nd4.previous_ptr=&nd3;
    nd3.previous_ptr=&nd2;
    nd2.previous_ptr=&nd1;
    nd1.previous_ptr=NULL;
    //left to right
    while(ptr1!=NULL)
    {   
        printf("%d \n",ptr1->val);
        ptr1=ptr1->next_ptr;
    }
    //right to left
    while(ptr2!=NULL)
    {
        printf("%d \n",ptr2->val);
        ptr2=ptr2->previous_ptr;
    }
}
